package DAO;

import java.sql.*;
import java.util.List;
import java.util.Set;

public abstract class DAO<T> {

    protected Connection connexion;

    public DAO(Connection c){
    	connexion = c;
    }

    protected PreparedStatement read(String req){
        try{
            PreparedStatement st = connexion.prepareStatement(req);
            return st;
        }catch(SQLException e){
            System.out.println("SQLException: " + e.getMessage());
            System.out.println("SQLState: " + e.getSQLState());
            System.out.println("VendorError: " + e.getErrorCode());
            return null;
        }
    }

    public abstract boolean update(T obj);

    public abstract boolean delete(T obj);

    public abstract boolean insert(T obj);
    
    public abstract T find(long id);

    public abstract Set<T> recherche(List<String> list);
}
